package com.ruoyi.airspaceFlight.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;


import com.ruoyi.airspaceFlight.dto.req.AirspaceApplyAndFileDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.airspaceFlight.domain.AirspaceApply;
import com.ruoyi.airspaceFlight.service.IAirspaceApplyService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 空域申请Controller
 * @author zc
 * @date 2023-11-04
 */
@RestController
@RequestMapping("/apply")
public class AirspaceApplyController extends BaseController
{
    @Autowired
    private IAirspaceApplyService airspaceApplyService;

    /**
     * 查询空域申请列表
     */
//    @RequiresPermissions("airspaceFlight:apply:list")
    @PostMapping("/list")
    public TableDataInfo list(@RequestBody AirspaceApply airspaceApply)
    {
        startPage();
        List<AirspaceApply> list = airspaceApplyService.selectAirspaceApplyList(airspaceApply);
        return getDataTable(list);
    }


    /**
     * 导出空域申请列表
     */
////    @RequiresPermissions("airspaceFlight:apply:export")
//    @Log(title = "空域申请", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, AirspaceApply airspaceApply)
//    {
//        List<AirspaceApply> list = airspaceApplyService.selectAirspaceApplyList(airspaceApply);
//        ExcelUtil<AirspaceApply> util = new ExcelUtil<AirspaceApply>(AirspaceApply.class);
//        util.exportExcel(response, list, "空域申请数据");
//    }

    /**
     * 获取空域申请详细信息
     */
//    @RequiresPermissions("airspaceFlight:apply:query")
    @GetMapping(value = "/{airspaceApplyId}")
    public AjaxResult getInfo(@PathVariable("airspaceApplyId") String airspaceApplyId)
    {
        return AjaxResult.success(airspaceApplyService.selectAirspaceApplyByAirspaceApplyId(airspaceApplyId));
    }

    /**
     * 新增空域申请
     */
//    @RequiresPermissions("airspaceFlight:apply:add")
    @Log(title = "空域申请", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add( @RequestBody AirspaceApplyAndFileDto airspaceApplyAndFileDto)
    {
        return toAjax(airspaceApplyService.insertAirspaceApply(airspaceApplyAndFileDto));
    }

    /**
     * 修改空域申请
     */
//    @RequiresPermissions("airspaceFlight:apply:edit")
    @Log(title = "空域申请", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AirspaceApplyAndFileDto airspaceApplyAndFileDto)
    {
        return toAjax(airspaceApplyService.updateAirspaceApply(airspaceApplyAndFileDto));
    }

    /**
     * 删除空域申请
     */
    @RequiresPermissions("airspaceFlight:apply:remove")
    @Log(title = "空域申请", businessType = BusinessType.DELETE)
	@DeleteMapping("/{airspaceApplyIds}")
    public AjaxResult remove(@PathVariable String[] airspaceApplyIds)
    {
        return toAjax(airspaceApplyService.deleteAirspaceApplyByAirspaceApplyIds(airspaceApplyIds));
    }
}
